﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.Supervise.IBLL;
using HZ.Supervise.Model;
using System.Data;

public partial class EarlyWarning_PurchaseOrderDetail : BasePage
{
    public EarlyWarning_PurchaseOrderDetail()
    { }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();

        }
    }
    private void BindData()
    {
        int irecord = 0;
        string strAreaID = HZ.Fun.CheckString(Request.QueryString["AreaID"].ToString());
        string strProcureCatalogID = HZ.Fun.CheckString(Request.QueryString["ProcureCatalogID"].ToString());
        string strHospitalID = HZ.Fun.CheckString(Request.QueryString["HospitalID"].ToString());

        int WarningDate = int.Parse(HZ.Fun.CheckString(Request.QueryString["WarningDate"].ToString()));
        int iWarningCount = int.Parse(HZ.Fun.CheckString(Request.QueryString["WarningCount"].ToString()));
        decimal iWarningAmount = decimal.Parse(HZ.Fun.CheckString(Request.QueryString["WarningAmount"].ToString()));
        HZ.Supervise.Model.Query.mQuery query = new HZ.Supervise.Model.Query.mQuery();
        query.AreaID = strAreaID;

        query.HospitalID = strHospitalID;
        query.ProcureCatalogID = strProcureCatalogID;
        query.SortFields = "HospitalID";
        HZ.Supervise.IBLL.IBLL_WarningData iWarningData = HZ.Supervise.BLLFactory.IBLL_WarningData();
        DataTable dt = iWarningData.GetOrderOverWarning(query, WarningDate, iWarningCount, iWarningAmount, this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, out irecord);
        this.gvwInfo.DataSource = dt;
        this.gvwInfo.DataBind();
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindData();
    }
    protected void gvwInfo_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[1].Text = Request.QueryString["WarningCount"].ToString();
            e.Row.Cells[2].Text = Request.QueryString["WarningAmount"].ToString();
        }
    }
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        int irecord = 0;
        string strAreaID = Request.QueryString["AreaID"].ToString();
        string strProcureCatalogID = Request.QueryString["ProcureCatalogID"].ToString();
        string strHospitalID = Request.QueryString["HospitalID"].ToString();

        int WarningDate = int.Parse(Request.QueryString["WarningDate"].ToString());
        int iWarningCount = int.Parse(Request.QueryString["WarningCount"].ToString());
        decimal iWarningAmount = decimal.Parse(Request.QueryString["WarningAmount"].ToString());
        HZ.Supervise.Model.Query.mQuery query = new HZ.Supervise.Model.Query.mQuery();
        query.AreaID = strAreaID;

        query.HospitalID = strHospitalID;
        query.ProcureCatalogID = strProcureCatalogID;
        query.SortFields = "HospitalID";
        HZ.Supervise.IBLL.IBLL_WarningData iWarningData = HZ.Supervise.BLLFactory.IBLL_WarningData();
        DataTable dt = iWarningData.GetOrderOverWarning(query, WarningDate, iWarningCount, iWarningAmount, 0, 0, out irecord);

        ExportFile.Instance.ExportData(dt, gvwInfo, this.Page);
    }
}
